package ke07.pm.reihe4;
	
public class FirstHundredItemBag{
	public static int counter;
	public Object[] list= new Object[100];
	
	public FirstHundredItemBag(){
		counter=0;
	}
	
	
	public boolean add(Object obj) {
		list[counter]=obj;
		counter++;
		for (int i=0; i<counter+1; i++){
			if (obj.equals(list[i])){
				return true;
			}
		}
		return false;		
	}


	public boolean contains(Object obj) {
		boolean enthaelt = false;
		for (int i = 0; i <= 100; i++){
			if (list[i].equals(obj)){
				enthaelt = true;
				break;
				}
		}
		return enthaelt;
	}


	public int count(Object obj) {
		int zahl=0;
		for(int i=0; i<counter; i++)
		{
			if(obj.equals(list[i])){
				zahl++;
			}
		}
		return zahl;
	}

	
	public boolean remove(Object obj) {
		for(int i = 0; i<counter+1; i++)
		{
			if (list[i]==obj){
				list[i]=list[counter];
				list[counter]=null;
			}
		}
		return false;
	}


	public int size() {		
		return counter;
	}


	public Object[] toArray() {		
		return list;
	}

}
